<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单</title>
    <style>
        .container {
            
            width: 400px;
            height: 700px;
            margin: 0 auto;
            padding: 20px;
            border: 1px solid #ccc;
           box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .captcha-container {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .captcha-image {
            height: 20px;
            background-color: #05c8eb;
            border: 1px solid #ccc;
            padding: 5px 10px;
            cursor: pointer;
            user-select: none;
        }

        .salary-container {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .salary-slider {
            width: 200px;
        }

        .salary-value {
            font-weight: bold;
            color: #333;
            min-width: 60px;
        }
        
        /* 图片预览样式 */
        .image-preview-container {
            margin-top: 10px;
        }
        
        .image-preview {
            max-width: 200px;
            max-height: 200px;
            display: none;
            border: 1px solid #ccc;
            padding: 5px;
        }
        #submit-container {
            text-align: center;
            margin-top: 20px;
            display: flex;
            width: 100%;
            border-color: #ccc;
            justify-content: center;
            background-color: #05c8eb;
              color: white; 
        }
    </style>
</head>

<body>
    <div class="container">
        <span style="color: red;"> 欢迎注册会员</span>
        <form action="data.html" method="get">
            <div>
                <label for="phone">手机号码：</label>
                <input type="text" id="phone" name="phone" placeholder="请输入手机号" required>
            </div>
            <div>
                <label for="password">密码：</label>
                <input type="password" id="password" name="password" placeholder="请输入8位密码" required maxlength="8">
            </div>
            <div>
                <label for="email">注册邮箱：</label>
                <input type="email" id="email" name="email" placeholder="例如qq号@qq.om" required>
            </div>
            <div class="captcha-container">
                <label for="code">验证码：</label>
                <input type="text" id="code" name="code" required>
                <div class="captcha-image" onclick="refreshCaptcha()" id="captchaImage"> </div>
            </div>
            <div>
                性别：
                <label for="male">男</label>
                <input type="radio" name="gender" value="male"> 男
                <label for="female">女</label>
                <input type="radio" name="gender" value="female"> 女
            </div>
            <div>
                生日：
                <input type="date" id="birthday" name="birthday">
            </div>
            <div>
                年龄：
                <input type="number" id="age" name="age" min="1" max="100" value="18" step="1">
            </div>

            <div>
                籍贯：
                <input type="text" id="nativePlace" name="nativePlace">
            </div>
            <div>
                个人学历：
                <select id="education" name="education">
                    <option value="university">本科</option>
                    <option value="primary">小学</option>
                    <option value="middle">中学</option>
                    <option value="high">高中</option>
                    <option value="college">大专</option>
                </select>
            </div>
            <div>
                <div class="salary-container">
                    薪水：<input type="range" id="salary" name="salary" class="salary-slider" min="1000" max="10000"
                        value="1000" step="1" oninput="updateSalaryValue(this.value)">
                    <span id="salaryValue" class="salary-value">1000</span>
                </div>
            </div>
            <div>
                个人爱好：
                <input type="checkbox" name="hobby" value="reading"> 阅读
                <input type="checkbox" name="hobby" value="sports"> 运动
                <input type="checkbox" name="hobby" value="music"> 音乐
                <input type="checkbox" name="hobby" value="game"> 游戏
            </div>
            <div>
                个人照片：<input type="file" id="photo" name="photo" accept="image/*" onchange="previewImage(event)">
                <!-- 图片预览区域 -->
                <div class="image-preview-container">
                    <img id="imagePreview" class="image-preview" alt="预览图片">
                </div>
            </div>
            <div>
                个人介绍：<textarea id="introduction" name="introduction" rows="4" cols="30"></textarea>
            </div>
            <div >
                <input id="submit-container" type="submit" value="注册">
                <input id="submit-container" type="reset" value="重置">
            </div>
        </form>
    </div>

    <script>
        // 刷新验证码函数
        function refreshCaptcha() {
            // 生成随机验证码（实际项目中应由后端生成）
            const chars = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
            let captcha = '';
            for (let i = 0; i < 4; i++) {
                captcha += chars.charAt(Math.floor(Math.random() * chars.length));
            }
            document.getElementById('captchaImage').textContent = captcha;
        }
        
        function updateSalaryValue(value) {
            document.getElementById('salaryValue').textContent = value;
        }
        
        // 图片预览函数
        function previewImage(event) {
            const file = event.target.files[0];
            const preview = document.getElementById('imagePreview');
            
            if (file) {
                const reader = new FileReader();
                
                reader.onload = function(e) {
                    preview.src = e.target.result;
                    preview.style.display = 'block';
                }
                
                reader.readAsDataURL(file);
            } else {
                preview.style.display = 'none';
            }
        }

        // 页面加载时生成初始验证码
        window.onload = function () {
            refreshCaptcha();
        };
    </script>
</body>

</html>